Jquery: Getting certain url path using window.location - Stack Overflow 2011年6月18日 - I think you want window.location.pathname. This would give you /index.com. To get rid of the leading /, you could simply use substring: